package com.qingge.springboot.common.controller;


import com.qingge.springboot.common.Result;
import com.qingge.springboot.utils.PhotoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/photo")
public class PhotoController {

    @Autowired
    private PhotoUtils photoUtils;

    @PostMapping("/upload")
    public Result upload(@RequestPart MultipartFile file) {
        String url = photoUtils.savePhoto(file);
        if (url == null) {
            return Result.error("保存失败!");
        }
        return Result.success(url);
    }

}

